import Layout from '../layout/Layout'
import Chat from '../views/chat'
import Request from '../views/request'
import Login from '../views/Login'
import PrivateRoute from './PrivateRoute' // 导入 PrivateRoute 组件

import { createBrowserRouter, createHashRouter } from 'react-router-dom'

const router = createBrowserRouter([
  {
    path: '/',
    element: <PrivateRoute element={<Layout />} /> ,
    children: [
      // 设置为默认二级路由 一级路由访问的时候，它也能得到渲染
      {
        index: true,
        // element:  <PrivateRoute element={<Chat />} />
        element:  <Chat />
      },
      {
        path: 'request',
        // element: <PrivateRoute element={<Request />} />
        element: <Request /> 
      }
    ]
  },
  {
    path: '/login',
    element: <Login />
  }
])

console.log(router)

export default router